package com.nantai.jiafang.nantaijiafang.deviceManager.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import com.nantai.jiafang.nantaijiafang.R;
import com.nantai.jiafang.nantaijiafang.deviceManager.bean.ReasonBen;

import java.util.List;

/**
 * Created by xxfreedom on 2017/3/5.
 */

public class ReasonAdapter extends BaseAdapter{
    private List<ReasonBen> reasonList;
    private LayoutInflater inflater;

    public ReasonAdapter(Context context, List items) {
        this.reasonList = items;
        this.inflater=LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return reasonList.size();
    }

    @Override
    public ReasonBen getItem(int position) {
            return reasonList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        //加载布局为一个视图
        View view=inflater.inflate(R.layout.reason_item,null);
        ReasonBen reasonBen=getItem(position);
        TextView reason_tv= (TextView) view.findViewById(R.id.reason_tv);
        reason_tv.setText(reasonBen.getName());
        return view;
    }
}

